<?
/* $Id: perm.php 62 2011-02-22 17:02:56Z jim2212001@gmail.com $ */
if(!defined('WEBHOME'))
	die ('DO NOT EXECUTE THIS FILE');

define(PERM_FOUNDER,	0x000001);
define(PERM_FOLLOWER,	0x000002);
define(PERM_ADMIN,		0x100000);

function hasPerm($perm){
	if(!isset($_SESSION['login'],$_SESSION['perm']))return false;
  	if(($_SESSION['perm']&PERM_ADMIN) == PERM_ADMIN)return true;
	return ((intval($_SESSION['perm'])&$perm) == $perm);
}
function requirePerm($perm){
	if(!hasPerm($perm)){
		errMsg(MSG_PERMISSION_DENIED);
	}
}
function isLogin(){
	return isset($_SESSION['login']);
}
function doLogin(){
  	infoMsg(MSG_LOGIN_PLEASELOGIN);
	redirectMsg('login.php');
}
function isAdmin(){
	return hasPerm(PERM_ADMIN);
}
?>
